package com.cc.blog.web.controller;

import com.cc.blog.common.annotation.ApiOperationLog;
import com.cc.blog.common.utils.Result;
import com.cc.blog.web.domain.dto.FindCommentListReqDTO;
import com.cc.blog.web.domain.dto.FindQQUserInfoReqDTO;
import com.cc.blog.web.domain.dto.PublishCommentReqDTO;
import com.cc.blog.web.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author cc
 * @Date 2025/1/13 17:00
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评论")
@AllArgsConstructor
public class CommentController {

    private final CommentService commentService;

    @PostMapping("/qq/userInfo")
    @ApiOperation(value = "获取 QQ 用户信息")
    @ApiOperationLog(description = "获取 QQ 用户信息")
    public Result findQQUserInfo(@RequestBody @Validated FindQQUserInfoReqDTO findQQUserInfoReqDTO) {
        return commentService.findQQUserInfo(findQQUserInfoReqDTO);
    }

    @PostMapping("/publish")
    @ApiOperation(value = "发布评论")
    @ApiOperationLog(description = "发布评论")
    public Result publishComment(@RequestBody @Validated PublishCommentReqDTO publishCommentReqDTO) {
        return commentService.publishComment(publishCommentReqDTO);
    }

    @PostMapping("/list")
    @ApiOperation(value = "获取页面所有评论")
    @ApiOperationLog(description = "获取页面所有评论")
    public Result findPageComments(@RequestBody @Validated FindCommentListReqDTO findCommentListReqDTO) {
        return commentService.findCommentList(findCommentListReqDTO);
    }
}
